window: Don't get surfaces needlessly
authorMatthias Clasen <mclasen@redhat.com>
Sun, 27 Sep 2020 12:57:05 +0000 (08:57 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 29 Sep 2020 00:51:13 +0000 (20:51 -0400)
There is a 1-1 correspondence between natives and
surfaces, so we can just compare the natives, no
need to get the surface for every single one.

gtk/gtkwindow.c

index dccb6644f2a2269116af0a098b1c8f042b484e6f..aecafe43bed82b706f4d9347552b86966aa8fc59 100644 (file)
@@ -7015,16 +7015,18 @@ update_cursor (GtkWindow *toplevel,
 {
   GtkWindowPrivate *priv = gtk_window_get_instance_private (toplevel);
   GdkCursor *cursor = NULL;
+  GtkNative *native;
   GdkSurface *surface;
 
-  surface = gtk_native_get_surface (gtk_widget_get_native (target));
+  native = gtk_widget_get_native (target);
+  surface = gtk_native_get_surface (native);
 
   if (grab_widget && !gtk_widget_is_ancestor (target, grab_widget) && target != grab_widget)
     {
       /* Outside the grab widget, cursor stays to whatever the grab
        * widget says.
        */
-      if (gtk_native_get_surface (gtk_widget_get_native (grab_widget)) == surface)
+      if (gtk_widget_get_native (grab_widget) == native)
         cursor = gtk_widget_get_cursor (grab_widget);
       else
         cursor = NULL;
@@ -7037,7 +7039,7 @@ update_cursor (GtkWindow *toplevel,
       while (target)
         {
           /* Don't inherit cursors across surfaces */
-          if (surface != gtk_native_get_surface (gtk_widget_get_native (target)))
+          if (native != gtk_widget_get_native (target))
             break;
 
           if (target == GTK_WIDGET (toplevel) && priv->resize_cursor != NULL)